package com.zhang.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhang.mapper.ISchoolMapper;
import com.zhang.pojo.School;
import com.zhang.service.ISchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SchoolServiceImpl implements ISchoolService {

    @Autowired
    private ISchoolMapper schoolMapper;

    @Override
    public PageInfo<School> findByItem(int pageNo, String name, Integer city, String status) {
        PageHelper.startPage(pageNo,5);
        PageInfo<School> school = PageInfo.of(schoolMapper.findByItem(name, city, status));
        return school;
    }

    @Override
    public void addSchool(School school) {
        schoolMapper.addSchool(school);
    }

    @Override
    public School queryById(int schoolId) {
        return schoolMapper.queryById(schoolId);
    }

    @Override
    public PageInfo<School> queryByCity(int cityId, int pageNo) {
        PageHelper.startPage(pageNo,5);
        PageInfo<School> school = PageInfo.of(schoolMapper.queryByCity(cityId));
        return school;
    }

    @Override
    public void allow(String status, int schoolId) {
        schoolMapper.allow(status,schoolId);
    }

    @Override
    public void noAllow(String status, int schoolId) {
        schoolMapper.allow(status,schoolId);
    }

    @Override
    public void update(String status, String opinion, int schoolId) {
        schoolMapper.update(status, opinion, schoolId);
    }
}
